<template>
	<view class="beijingse">
		<view class="zzdbbox">
			<view class="strongtext xiaobai fonweight">可提现</view>
			<view class="sishi xiaobai margin_top2 fonweight">￥
				<text class="xiaobai fonweight" style="font-size: 70rpx;" v-if="type==1">{{userInfo.score}}</text>
				<text class="xiaobai fonweight" style="font-size: 70rpx;" v-if="type==2">{{userInfo.bzj_price}}</text>
			</view>
		</view>
		<view class="mainpadding" style="position: relative; top: -110rpx;">
			<view class="ffffff radius mainpadding">
				<view class="ershiba xiaohei" v-if="type==1">提现积分（个）</view>
				<view class="ershiba xiaohei" v-if="type==2">提现金额（元）</view>
				<view class="flexbetween margin_top2">
					<view class="sishi xiaohei margin_top2 flexleft fonweight">￥
						<input type="number" class="xiaohei fonweight" style="font-size: 64rpx;" v-model="score" name="" id="">
					</view>
					<view class="ershiba xiaocheng" style="min-width: 120rpx ;" v-if="type==1" @click="score = userInfo.score">全部提现</view>
					<view class="ershiba xiaocheng" style="min-width: 120rpx ;" v-if="type==2" @click="score = userInfo.bzj_price">全部提现</view>
				</view>
			</view>
			<view class="mainpadding radius ffffff margin_top">
				<view class="ershiba zhonghei">提现至</view>
				<view class="flexbetween margin_top">
					<view class="flexleft">
						<view class="margin_right1">
							<u-icon name="zhifubao-circle-fill" color="#5c9cf6" size="22"></u-icon>
						</view>
						<view class="ershiba xiaohei">支付宝</view>
					</view>
					<u-icon name="checkmark-circle-fill" color="#FF9341" size="18"></u-icon>
				</view>
			</view>
			<view class="bigbtn " style="margin-top: 180rpx;" @click="submit">提现</view>
			<view class="xiaocheng textcenter margin_top sanshier" v-if="type==1" @click="jumpurl('/pages_mypage/tixianjil')">提现记录</view>
		</view>
	</view>
</template>
<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				userInfo: {},
				score: "", 
				type:1,//1积分提现，2保证金提现
			}
		},
		onLoad(options) {
			this.type = options.type
			this.userinfomsg()
		},
		methods: {
			userinfomsg() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			submit(){
				if(this.score=="" && this.type==1){
					httpRequest.toast("请输入提现积分")
					return false
				}
				if(Number(this.score)>Number(this.userInfo.score) && this.type==1){
					httpRequest.toast("提现积分不可大于可提现积分")
					return false
				}
				if(this.score=="" && this.type==2){
					httpRequest.toast("请输入提现金额")
					return false
				}
				if(Number(this.score)>Number(this.userInfo.bzj_price) && this.type==2){
					httpRequest.toast("提现金额不可大于可提现金额")
					return false
				}
				let data = {
					score:this.score
				}
				let url = "/api/user/addWithdrawal"
				if(this.type==2){
					url = "/api/bzjcl/bzjWithdrawal"
					data = {
						money:this.score
					}
				}
				httpRequest.request(url, 'GET', data).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.zzdbbox {
		background-size: 100% 100%;
		padding: 16rpx 30rpx 100rpx;
		// background-image: url('https://kuaixun.yuntaiqikeji.com/uploads/20240115/72aba476733bb7cd89b5910c897ea17b.png');
		background-color: #ff8506;
	}
</style>